#include "logindialog.h"
#include "ui_logindialog.h"
#include "employclient.h"

loginDialog::loginDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::loginDialog)
{
    ui->setupUi(this);

    //设置窗口的主题
    this->setWindowTitle("员工管理系统客户登录框");
    QIcon icon = QIcon("D:/Qt_Test/employmanage/icon/employ.png");
    this->setWindowIcon(icon);

    //给登录和取消按钮添加图标
    icon = QIcon("D:/Qt_Test/employmanage/icon/Login.png");
    ui->buttonBox->button(QDialogButtonBox::Ok)->setIcon(icon);

    icon = QIcon("D:/Qt_Test/employmanage/icon/cancel.png");
    ui->buttonBox->button(QDialogButtonBox::Cancel)->setIcon(icon);

    //修改buttonBox按钮盒子上的内容为登录或者取消
    //1.获取要修改的按钮
    QPushButton *loginBtn = ui->buttonBox->button(QDialogButtonBox::Ok);
    //2.修改按钮中的文本
    loginBtn->setText("登录");

    ui->buttonBox->button(QDialogButtonBox::Cancel)->setText("取消");

    //显示logo
    QPixmap pix = QPixmap("D:/Qt_Test/employmanage/icon/logo.png");
    ui->LOGOlabel->setPixmap(pix);

}

loginDialog::~loginDialog()
{
    delete ui;
}

void loginDialog::on_buttonBox_accepted()
{
    QString msg = "1^@^" + ui->workNumEdit->text() + "^@^" + ui->passwordEdit->text() + "^@^";
    //调用发送函数
    sendMessage(msg.toLocal8Bit());

}


void loginDialog::on_buttonBox_rejected()
{
    QMessageBox::StandardButton btn =
            QMessageBox::information(
                this,
                "取消登录",
                "你真的要取消登录吗？",
                QMessageBox::Yes|QMessageBox::No);
    if(btn == QMessageBox::Yes){
        this->close();
    } else{

    }

}

